#!/usr/bin/env python
#coding:utf-8
import cgi
import sys
import sqlite3
import cgitb;cgitb.enable()

conn = sqlite3.connect("input.db")
curs = conn.cursor()

form = cgi.FieldStorage()

name = form.getvalue("name")
email = form.getvalue("email")
#print "Content-type: text/html"
print "Location: /wiki/add/input.html\n"
print
print "<html><body>"
if not (name and email):
    print "请输入名字和电子邮件"
    sys.exit()

query = """insert into address(name, email) values('%s', '%s')""" % (name, email)
curs.execute(query)
conn.commit()
#conn.close()
print "<p><em>数据保存成功！</em></p>"
print "</body></html>"

